/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.vsu.cs.kis.elections.dto;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * 
 * @author Kirill
 */
@SuppressWarnings("serial")
public class PrecinctDto implements Serializable {
	
	private int id;

	private String address;

	private int state;

	private String password;

	private ArrayList<CandidateDto> candidates;

	public PrecinctDto() {
		candidates = new ArrayList<CandidateDto>();
	}
	
	
	public void randomVotes(){
		for (CandidateDto item:candidates) {
			item.random(); 
		}	
	}
	
	public PrecinctDto(String address, String pw) {
		this(0,address,0,pw);
	}	
	
	
	public PrecinctDto(int id, String address, int state, String pw) {
		candidates = new ArrayList<CandidateDto>();
		this.id = id;
		this.address = address;
		this.state = state;
		this.password = pw;
	}	

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public ArrayList<CandidateDto> getCandidates() {
		return candidates;
	}

	public void setCandidates(ArrayList<CandidateDto> candidates) {
		this.candidates = candidates;
	}
	
	public void addCandidate(CandidateDto candidate) {
		if (candidates == null){
			candidates = new ArrayList<CandidateDto>();
		}
		this.candidates.add(candidate);
	}	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
}
